package com.lb.activity.rest;

import com.lb.activity.po.WebArticleComment;
import com.lb.activity.service.TextService;
import com.lb.activity.util.ResultUtil;
import com.lb.activity.vo.ArticleVo;
import feign.Headers;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;


@RestController
public class TextController {

    @Resource
    private TextService textService;

    /**
     * eurkea rest接口请求文章
     * @param page
     * @return
     */
    @GetMapping("rest/texts")
    public Object restTexts(Integer page){
        Map<String,Object> map = textService.restTexts(page);
        return map;
    }

    @GetMapping("show/{id}")
    public ArticleVo showData(@PathVariable("id")Long id){
        ArticleVo webArticle = textService.showData(id);
        return webArticle;
    }

    @GetMapping("sync/data")
    public void syncInfo(){
        textService.syncData();
    }


    @GetMapping("webArticles")
    public List<ArticleVo> webArticles(){
        List<ArticleVo> articleVos = textService.arts();
        return articleVos;
    }

    @PostMapping("addComment")
    public Object addComment(@RequestBody WebArticleComment webArticleComment){
        ResultUtil resultUtil = textService.addComment(webArticleComment);
        return resultUtil;
    }

    @PostMapping("comments")
    public Object comments(@RequestParam("actId") Long actId){
        ResultUtil resultUtil = textService.comments(actId);
        return resultUtil;
    }


    @PostMapping("hotCommentAct")
    public Object hotCommentAct(){
        ResultUtil resultUtil = textService.hotCommentAct();
        return resultUtil;
    }
}
